In vector encoding technologies, an algebraic codebook is often used to perform quantization encoding on a residual signal after adaptive filtering. After position and symbol information of an optimal algebraic codebook pulse on a track is obtained through searching, a corresponding index value is obtained through encoding calculation, so that a decoding end can reconstruct a pulse sequence according to the index value. In a precondition that lossless reconstruction is ensured, bits required by a code index value are reduced as much as possible, which is one of the major objectives of research and development of algebraic codebook pulse encoding methods.
A preferred encoding method, namely, the adaptive multi-rate wideband (AMR_WB+, Adaptive Multi-Rate Wideband) encoding method in speech encoding is taken as an example below to illustrate a specific encoding method adopted by an existing algebraic codebook pulse. According to different code bit rates, 1 to N pulses may be encoded on each track. It is assumed that each track has M=2m positions, in the AMR_WB+, processes of encoding 1 to 6 pulses on each track are respectively described as follows:
One pulse is encoded on each track.
Each track has 2m positions, therefore on each track, a position index of the pulse requires m bits for encoding, and a symbol index of the pulse requires 1 bit for encoding. An index value of 1 pulse with a symbol is encoded as:I1p(m)=p+s×2m,
where pε[0, 2m−1] is the position index of the pulse; s is the symbol index of the pulse; when a pulse symbol is positive, s is set as 0, and when the pulse symbol is negative, s is set as 1; I1pe[0, 2m+1−1].
The number of bits required for encoding 1 pulse on each track is: m+1.
Two pulses are encoded on each track.
According to the result of {circle around (1)}, m+1 bits are required for encoding 1 pulse on each track, and encoding a position index of the other pulse requires m bits. Because there is no special requirement for order of the pulses, a value relationship obtained by arraying position indexes of the pulses may be used to indicate a symbol of the other pulse. An index value of 2 pulses is encoded as:I2p(m)=p1+I1p0×2m=p1+p0×2m+s×22m,
where p0, p1ε[0, 2m−1] are the position indexes of the 2 pulses respectively; s is a symbol index of a pulse p0; a specific symbol indication rule of a pulse p1 is: p0<p1 indicates that 2 pulse symbols are the same, p0>p1 indicates that 2 pulse symbols are opposite to each other; I2pε[0, 22m+1−1].
The number of bits required for encoding 2 pulses on each track is: 2m+1.
Three pulses are encoded on each track.
Each track is divided into two sections: Section A and Section B. Each section individually includes 2m−1 positions. A certain section includes at least 2 pulses. According to the result of {circle around (5)}, 2×(m−1)+1=2m−1 bits are required for encoding the section. Another pulse is searched for on the whole track, and according to the result of {circle around (1)}, m+1 bits are required. In addition, 1 bit is further required to indicate the section including 2 pulses. An index value of 3 pulses is encoded as:I3p(m)=I2p(m−1)+k×22m-1+I1p(m)×22m,
where k is an index of the Section; I3pε[0, 23m+1−1].
The number of bits required for encoding 3 pulses on each track is: 3m+1.
Four pulses are encoded on each track.
Each track is divided into two sections: Section A and Section B. Each section individually includes 2m−1 positions. Combinations of the numbers of pulses included in each section are as shown in the following table.
The number of pulsesThe number of pulses inTypein Section ASection BRequired bits0044m-31134m-22224m-23314m-24404m-3
In the foregoing table, bases of the required bits corresponding to each type are: For type 0 and type 4, in a section having 4 pulses, the method similar to that of {circle around (3)} is adopted, but the number of pulses for overall searching is 2, which is equivalent to I2p(m−2)+k×22m-3+I2p(m−1)×22m-2; for type 1, it is equivalent to I1p(m−1)+I3p(m−1)×2m; for type 2, it is equivalent to I2p(m−1)+I2p(m−1)×22m-1; and for type 3, it is equivalent to I3p(m−1)+I1p(m−1)×23m-2.
Type 0 and type 4 are regarded as a possible situation, and types 1 to 3 each are regarded as a situation, so that totally there are 4 situations, therefore 2 bits are required to indicate corresponding situations, and types 1 to 3 each require 4m−2+2=4m bits. Furthermore, for the situation including type 0 and type 4, 1 bit is further required for distinction, so that type 0 and type 4 require 4m−3+2+1=4m bits.
The number of bits required for encoding 4 pulses on each track is: 4m.
Five pulses are encoded on each track.
Each track is divided into two sections: Section A and Section B. Each section individually includes 2m−1 positions. A certain section includes at least 3 pulses. According to the result of {circle around (3)}, 3×(m−1)+1=3m−2 bits are required for encoding the section. The other two pulses are searched for on the whole track, and according to the result of {circle around (2)}, 2m+1 bits are required. In addition, 1 bit is further required to indicate the section including 3 pulses. An index value of 5 pulses is encoded as:I5p(m)=I3p(m−1)+k×23m-2+I1p(m)×23m-1.
The number of bits required for encoding 5 pulses on each track is: 5m.
Six pulses are encoded on each track.
Each track is divided into two sections: Section A and Section B. Each section individually includes 2m−1 positions. Combinations of the numbers of pulses included in each section are as shown in the following table.
The number of pulsesThe number of pulses inTypein Section ASection BRequired bits0066m-51156m-52246m-53336m-44426m-55516m-56606m-5
In the foregoing table, bases of the required bits corresponding to each type may be deduced according to {circle around (4)}, which is not repeatedly described.
Types 0 and 6, types 1 and 5, types 2 and 4 are each regarded as a possible situation, and type 3 is separately regarded as a situation, so that totally there are 4 situations, therefore 2 bits are required to indicate corresponding situations, and type 3 requires 6m−4+2=6m−2 bits. For those situations including combined types, 1 bit is further required for distinction, so that other types, except for type 3, require 6m−5+2+1=6m−2 bits.
The number of bits required for encoding 6 pulses on each track is: 6m−2.
In the process of proposing the present invention, the inventor finds that: In the algebraic pulse encoding method provided by the AMR_WB+, encoding logic similar to recursion is adopted, a situation in which the number of encoded pulses is relatively large is divided into several situations in which the number of encoded pulses is relatively small for processing, therefore calculation is complicated, and meanwhile, as the number of encoded pulses on the track increases, redundancy of code indexes accumulates gradually, which easily causes waste of code bits.